﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class MyArray
    {
        //定义一个排序的方法
        public static void Sort(int[] nums)
        {
            //nums[0] = 999;
            //Console.WriteLine(nums[0]);
            int temp;
            for (int i = 0; i < nums.Length-1; i++)
            {
                for (int j = i+1; j < nums.Length; j++)
                {
                    if (nums[j] < nums[i])
                    {
                        temp = nums[i];
                        nums[i] = nums[j];
                        nums[j] = temp;
                    }
                }
            }
        }

        //定义打印输出数组的方法
        public static void Print(int[] arr)
        {
            foreach (int n in arr)
            {
                Console.Write(n + "\t");
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            //定义的同时初始化数组
            int[] arr = { 3, 1, 5, 2, 4 };

            //打印输出数组
            Print(arr);

            //对数组进行排序
            Sort(arr);

            //打印输出数组
            Print(arr);

            //Console.WriteLine(arr[0]);

        }
    }
}
